home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mgr / sparcmgr / src.zoo / src / fast_scroll.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-17  |  5.1 KB  |  172 lines

  1. /*                        Copyright (c) 1987 Bellcore
  2.  *                            All Rights Reserved
  3.  *       Permission is granted to copy or use this program, EXCEPT that it
  4.  *       may not be sold for profit, the copyright notice must be reproduced
  5.  *       on copies, and credit should be given to Bellcore where it is due.
  6.  *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  7.  */
  8. /*    $Header: fast_scroll.c,v 1.1 89/03/17 08:21:06 sau Exp $
  9.     $Source: /m1/mgr.new/src/RCS/fast_scroll.c,v $
  10. */
  11. static char    RCSid_[] = "$Source: /m1/mgr.new/src/RCS/fast_scroll.c,v $$Revision: 1.1 $";
  12.  
  13. /*
  14.  * fast scroll for 68010 assuming byte boundaries  (SAU)
  15.  *    This code is highly machine dependent
  16.  */
  17.  
  18. #include <stdio.h>
  19. #include "bitmap.h"
  20.  
  21. #define BYTESWIDE(x)    ((x->primary->wide+7)>>3)
  22.  
  23. #ifndef mc68020
  24.  
  25. /* these macros rely upon the proper register assignments */
  26.  
  27. #define START(x)    asm("x:    movl    d7,d0")
  28. #define LOOP(l)        asm("l:    movw    a3@+,a4@+"); \
  29.             asm("    dbf    d0,l")
  30. #define GOTO(x)        asm("    dbf    d5,x")
  31. #define SKIP()        asm("    addl    d6,a4"); \
  32.             asm("    addl    d6,a3")
  33. #define BYTE()        asm("    movb    a3@+,a4@+")
  34. #define ADJ(x)        asm("    subql    #x,d7")
  35.  
  36. fast_scroll(map,x,y,wide,high,delta)
  37. register BITMAP *map;                    /* a5 */
  38. int x,y,wide,high,delta;
  39.    {
  40.    register unsigned char *dst = (unsigned char *)     /* a4 */
  41.          ((long) (map->data) + (y*BYTESWIDE(map) + (x>>3)));
  42.    register unsigned char *src =            /* a3 */
  43.          dst + (delta*BYTESWIDE(map));
  44.    register long count =                /* d7 */
  45.          (wide>>4) - 1;            /* # of shorts - 1 for inner dbf */
  46.    register long skip =                 /* d6 */
  47.          BYTESWIDE(map)-(wide>>3);    /* bytes to skip at right edge */
  48.    register long h =                     /* d5 */
  49.          high-delta-1;            /* # of lines to scroll */
  50.    int which = (((long) dst)&1) + ((skip&1)<<1);
  51.  
  52.    switch (which) {
  53.       case 0:            /* skip&1 == 0 */
  54.      START(C0); LOOP(LP0); SKIP(); GOTO(C0);
  55.          break;
  56.       case 1:
  57.          ADJ(1); START(C1); BYTE(); LOOP(LP1); BYTE(); SKIP(); GOTO(C1);
  58.          break;
  59.  
  60.       case 2:            /* skip&1 == 1 */
  61.      START(C2); LOOP(LP2); BYTE(); SKIP(); GOTO(C2);
  62.          break;
  63.       case 3:
  64.      START(C3); BYTE(); LOOP(LP3); SKIP(); GOTO(C3);
  65.          break;
  66.       }
  67.    }
  68.  
  69. /*
  70.  * fast scroll for 68020 assuming byte boundaries  (SAU)
  71.  *    This code is highly machine dependent
  72.  */
  73.  
  74. #else
  75.  
  76. /* these macros rely upon the proper register assignments */
  77.  
  78. #define START(x)    asm("x:    movl    d7,d0")
  79. #define LOOP(l)        asm("l:    movl    a3@+,a4@+"); \
  80.             asm("    dbf    d0,l")
  81. #define GOTO(x)        asm("    dbf    d5,x")
  82. #define SKIP()        asm("    addl    d6,a4"); \
  83.             asm("    addl    d6,a3")
  84. #define WORD()        asm("    movw    a3@+,a4@+")
  85. #define BYTE()        asm("    movb    a3@+,a4@+")
  86. #define ADJ(x)        asm("    subql    #x,d7")
  87.  
  88. fast_scroll(map,x,y,wide,high,delta)
  89. register BITMAP *map;                    /* a5 */
  90. int x,y,wide,high,delta;
  91.    {
  92.    register unsigned char *dst = (unsigned char *)     /* a4 */
  93.          ((long) (map->data) + (y*BYTESWIDE(map) + (x>>3)));
  94.    register unsigned char *src =            /* a3 */
  95.          dst + (delta*BYTESWIDE(map));
  96.    register long count =                /* d7 */
  97.          (wide>>5) - 1;            /* # of longs - 1 for inner dbf */
  98.    register long skip =                 /* d6 */
  99.          BYTESWIDE(map)-(wide>>3);    /* bytes to skip at right edge */
  100.    register long h =                     /* d5 */
  101.          high-delta-1;            /* # of lines to scroll */
  102.    int which = (((long) dst)&3) + ((skip&3)<<2);
  103.  
  104.    switch (which) {
  105.       case 0:            /* skip&3 == 0 */
  106.      START(C0); LOOP(LP0); SKIP(); GOTO(C0);
  107.          break;
  108.       case 1:
  109.          ADJ(1); START(C1); BYTE(); WORD(); LOOP(LP1); BYTE(); SKIP(); GOTO(C1);
  110.          break;
  111.       case 2:
  112.          ADJ(1); START(C2); WORD(); LOOP(LP2); WORD(); SKIP(); GOTO(C2);
  113.          break;
  114.       case 3:
  115.          ADJ(1); START(C3); BYTE(); LOOP(LP3); WORD(); BYTE(); SKIP(); GOTO(C3);
  116.          break;
  117.  
  118.       case 4:            /* skip&3 == 1 */
  119.      START(C4); LOOP(LP4); WORD(); BYTE(); SKIP(); GOTO(C4);
  120.          break;
  121.       case 5:
  122.      START(C5); BYTE(); WORD(); LOOP(LP5); SKIP(); GOTO(C5);
  123.          break;
  124.       case 6:
  125.      START(C6); WORD(); LOOP(LP6); BYTE(); SKIP(); GOTO(C6);
  126.          break;
  127.       case 7:
  128.      START(C7); BYTE(); LOOP(LP7); WORD(); SKIP(); GOTO(C7);
  129.          break;
  130.  
  131.       case 8:            /* count%4 == 2 */
  132.      START(C8); LOOP(LP8); WORD(); SKIP(); GOTO(C8);
  133.          break;
  134.       case 9:
  135.          ADJ(1); START(C9); BYTE(); WORD(); LOOP(LP9);
  136.          WORD(); BYTE(); SKIP(); GOTO(C9);
  137.          break;
  138.       case 10:
  139.      START(C10); WORD(); LOOP(LP10); SKIP(); GOTO(C10);
  140.          break;
  141.       case 11:
  142.      START(C11); BYTE(); LOOP(LP11); BYTE(); SKIP(); GOTO(C11);
  143.          break;
  144.  
  145.       case 12:            /* count%4 == 3 */
  146.      START(C12); LOOP(LP12); BYTE(); SKIP(); GOTO(C12);
  147.          break;
  148.       case 13:
  149.          ADJ(1); START(C13); BYTE(); WORD(); LOOP(LP13);
  150.          WORD(); SKIP(); GOTO(C13);
  151.          break;
  152.       case 14:
  153.          ADJ(1); START(C14); WORD(); LOOP(LP14); WORD();
  154.          BYTE(); SKIP(); GOTO(C14);
  155.          break;
  156.       case 15:
  157.      START(C15); BYTE(); LOOP(LP15); SKIP(); GOTO(C15);
  158.          break;
  159.       }
  160.    }
  161.  
  162. /* normal bit-blit version of the above (for testing) */
  163.  
  164. Fast_scroll(map,x,y,wide,high,delta)
  165. register BITMAP *map;                    /* a5 */
  166. int x,y,wide,high,delta;
  167.    {
  168.    bit_blit(map,x&7,y,wide&7,high,
  169.             BIT_SRC,map,x&7,delta);
  170.    }
  171. #endif
  172.